import 'package:enter_prise_web/util/MyDio.dart';
import 'package:get/get.dart';

class settingController extends GetxController {
  final MyDio myDio = MyDio();

  var settings = [];

  @override
  void onInit() {
    // TODO: implement onInit
    super.onInit();
    getObjectData();
  }

  @override
  void onReady() {
    // TODO: implement onReady
    super.onReady();
  }

  void getObjectData() async {
    settings.clear();
    var response = await myDio.requestData("/item/listAll",method: 'GET');
    try {
      settings = response.data;
    } catch (e) {
      print(e);
    }
    update(['setting_list']);
  }

  void refreshData() async {
    getObjectData();
  }

  void deleteById(int index) {
    myDio.requestData("/item/delete?oid=${settings[index]['oid']}",method: 'GET');
    settings.removeAt(index);
    update(['setting_list']);
    update(['setting_list_web']);
  }
}
